{smcl}
{* *! version 1.0.0 15april2016}{...}
{cmd:help scurve_tvc}{right: ({browse "http://www.stata-journal.com/article.html?article=st0458":SJ16-4: st0458})}
{hline}

{title:Title}

{p2colset 5 19 21 2}{...}
{p2col:{hi:scurve_tvc} {hline 2}}Calculate survival curves from stcox with time-varying coefficients{p_end}


{marker syntax}{...}
{title:Syntax}

{p 8 18 2}
{cmd:scurve_tvc} {ifin}{cmd:,} {cmdab:gen:erate}{cmd:(}{it:newvar}{cmd:)}
{cmd:at(}{it:varname} {it:#} [{varname} {it:#} ...]{cmd:)} 
{opt tvc(varlist)}
{opt texp(string)} [{cmd:replace} {opt ties(stcox_ties)} {opt shared(varname)}
{opt strata(varname)} {opt graph} {opt plotopts(options)}]


{marker description}{...}
{title:Description}

{pstd}
{cmd:scurve_tvc} fits {cmd:stcox} with time-varying effects and calculates the
survival curve for specific covariate values.


{marker options}{...}
{title:Options}

{phang}
{opt generate(newvar)} creates the variable {it:newvar} to store the estimated
survival curve.  If you also specify {cmd:strata()}, then {cmd:scurve_tvc}
creates one variable for each stratum.  The corresponding analysis-time
variable, which allows us to plot the results, is saved in the new variable
{cmd:_tscurve}.  {cmd:generate()} is required.

{phang}
{opt at(varname # [varname # ...])} specifies the covariates included in the
model and the values for which the survival curve should be calculated.
{cmd:at()} is required.

{phang}
{opt tvc(varlist)} specifies the covariates with time-varying coefficients.
The variables in {cmd:tvc()} must also appear in {cmd:at()}.  {cmd:scurve_tvc}
will automatically {cmd:stsplit} the data at failure times to ensure a
correctly fit model.  See {helpb tvc note} for more information.  {cmd:tvc()}
is required.

{phang}
{opt texp(string)} specifies the function of analysis time according to which
the effect varies with time.  For example, specifying {cmd:texp(ln(_t))} would
cause the variables with time-varying coefficients to be multiplied by the
logarithm of analysis time.  {cmd:texp()} is required.

{phang}
{opt replace} specifies to replace the existing variable(s) with the new
estimates.

{phang}
{opt ties(stcox_ties)} specifies how {cmd:stcox} handles tied failure times.
See {manhelp stcox ST} for details.

{phang}
{opt shared(varname)} specifies a shared-frailty ID variable.  See 
{manhelp stcox ST} for details.

{phang}
{opt strata(varname)} specifies a strata ID variable.  See {manhelp stcox ST}
for details.

{phang}
{opt graph} plots the predicted survival curve.  If you also specify
{cmd:strata()}, then {opt graph} plots the survival estimates for each
stratum.

{phang}
{opt plotopts(options)} customizes the plot by using options allowed with
{manhelp graph_twoway_line G-2:graph twoway line}.


{marker examples}{...}
{title:Examples}

{phang}
{cmd:. webuse catheter}{p_end}
{phang}
{cmd:. generate id=_n}{p_end}
{phang}
{cmd:. stset time, failure(infect) id(id)}{p_end}
{phang}
{cmd:. scurve_tvc, generate(scurve1) at(female 0 age 43) tvc(female) texp(ln(_t))}{p_end}
{phang}
{cmd:. scurve_tvc, generate(scurve2) at(female 1 age 43) tvc(female) texp(ln(_t))}{p_end}
{phang}
{cmd:. twoway line scurve1 scurve2 _tscurve, connect(J J)}{p_end}


{title:Author}

{pstd}Constantin Ruhe{p_end}
{pstd}Department of Politics and Public Administration{p_end}
{pstd}University of Konstanz{p_end}
{pstd}Konstanz, Germany{p_end}
{pstd}Constantin.Ruhe@uni-konstanz.de{p_end}


{title:Also see}

{p 4 14 2}Article:  {it:Stata Journal}, volume 16, number 4: {browse "http://www.stata-journal.com/article.html?article=st0458":st0458}{p_end}
